#!/bin/bash

# 测试V3版本API
echo "===== 测试V3版本 ====="
echo "1. 健康检查"
curl -s http://localhost:8080/v3/health
echo -e "\n"

echo "2. 执行日报任务"
TASK_RESULT=$(curl -s http://localhost:8080/v3/report?type=日报)
echo $TASK_RESULT
echo -e "\n"

# 提取任务ID（简单处理）
TASK_ID=$(echo $TASK_RESULT | grep -o 'TASK_V3_[A-Z0-9]*')
if [ -z "$TASK_ID" ]; then
    echo "无法获取任务ID，跳过后续测试"
    exit 1
fi

echo "3. 查询任务状态: $TASK_ID"
curl -s http://localhost:8080/v3/task/status/$TASK_ID
echo -e "\n"

echo "4. 查询失败任务"
curl -s http://localhost:8080/v3/task/failed
echo -e "\n"

echo "5. 尝试恢复任务: $TASK_ID"
curl -s -X POST http://localhost:8080/v3/task/recover/$TASK_ID
echo -e "\n"

echo "6. 查看V3功能特性"
curl -s http://localhost:8080/v3/example
echo -e "\n"

echo "===== 测试完成 ====="
